package com.tencent.qf.activity.special.area.service.controller;


import com.tencent.qf.activity.special.area.service.dal.DO.JdGiftCouponTransferInfo;
import com.tencent.qf.activity.speical.area.api.dto.JdGiftCouponTransferCountDTO;
import com.tencent.qf.activity.speical.area.api.dto.JdGiftCouponTransferInfoDTO;
import com.tencent.qf.activity.special.area.service.service.JdGiftCouponTransferInfoService;
import com.tencent.qf.activity.speical.area.api.dto.SpecialAreaDisplayDTO;
import com.tencent.qf.activity.speical.area.api.dto.req.*;
import com.tencent.qf.activity.speical.area.api.dto.resp.SpecialAreaCouponResponse;
import com.tencent.qf.activity.speical.area.api.service.SpecialAreaService;
import com.tencent.qf.common.aspect.annotation.ApiLog;
import com.tencent.qf.common.aspect.annotation.Signature;
import com.tencent.qf.common.pojo.ActivityPlatformHttpResult;
import com.tencent.qf.common.pojo.HttpResult;
import com.tencent.qf.user.dto.response.SpecialAreaDisplayResponse;
import com.tencent.qf.user.service.ActivityPlatformService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author p_jongzheng@tencent.com
 * @create 2023/8/11 17:18
 * @description:
 */

@ApiModel("专区")
@RestController
@RequestMapping("/api/special/area")
@Api(tags = "专区")
public class SpecialAreaController {

    @Resource
    private SpecialAreaService specialAreaService;
    @Resource
    private JdGiftCouponTransferInfoService jdGiftCouponTransferInfoService;
    @Resource
    private ActivityPlatformService activityPlatformService;

    @ApiLog(value = "用户是否有资格领取专区优惠券（京享礼券）")
    @ApiOperation(value = "用户是否有资格领取专区优惠券（京享礼券）")
    @Signature
    @RequestMapping("/query/jdCouponInfo")
    public ActivityPlatformHttpResult<SpecialAreaCouponResponse> querySpecialAreaUserQualification(@RequestBody @Valid SpecialAreaCouponRequest specialAreaCouponRequest) {
        return ActivityPlatformHttpResult.success(specialAreaService.querySpecialAreaUserQualification(specialAreaCouponRequest));
    }

    @ApiLog(value = "专区转链推送")
    @ApiOperation(value = "专区转链推送")
    @Signature
    @RequestMapping("/transfer/push")
    public ActivityPlatformHttpResult specialAreaTransferPush(@RequestBody SpecialAreaTransferRequest request) {
        specialAreaService.specialAreaTransferPush(request);
        return ActivityPlatformHttpResult.success(true);
    }

    @ApiLog(value = "获取专区转链数")
    @Signature
    @RequestMapping("/transfer/count")
    @ApiOperation("获取专区转链数")
    public HttpResult<JdGiftCouponTransferCountDTO> transferCount(@RequestBody @Valid TransferCountRequest request) {
        JdGiftCouponTransferCountDTO transferCount = jdGiftCouponTransferInfoService.getTransferCount(request.getSpecialAreaId(), request.getTransferTime());
        return HttpResult.success(transferCount);
    }

    @ApiLog(value = "查询用户转链信息")
    @Signature
    @RequestMapping("/transfer/user/list")
    @ApiOperation("查询用户转链信息")
    public HttpResult<List<JdGiftCouponTransferInfo>> transferUserList(@RequestBody @Valid TransferUserListReq request) {
        List<JdGiftCouponTransferInfo> transferInfos = jdGiftCouponTransferInfoService.transferUserList(request);
        return HttpResult.success(transferInfos);
    }

    @ApiLog(value = "获取专区转链信息")
    @Signature
    @RequestMapping("/transfer/list")
    @ApiOperation("获取专区转链信息")
    public HttpResult<List<JdGiftCouponTransferInfoDTO>> transferList(@RequestBody @Valid TransferInfoRequest request) {
        List<JdGiftCouponTransferInfoDTO> transferInfos = jdGiftCouponTransferInfoService.getTransferInfo(request.getSpecialAreaId(), request.getUid());
        return HttpResult.success(transferInfos);
    }

    @ApiLog(value = "专区资格判断")
    @Signature
    @RequestMapping("/qualification/check")
    @ApiOperation("专区资格判断")
    public ActivityPlatformHttpResult<SpecialAreaDisplayResponse> qualificationCheck(@RequestBody @Valid TransferInfoRequest request) {
        return activityPlatformService.specialAreaDisplay(request.getSpecialAreaId(), request.getUid());
    }
}
